package com.bean;

import java.util.List;


public class DwzPage {
	//�ڶ���ʾ����
	private int pageNumShown = 4; // ҳ��   ���ֶ��ٸ���Ĭ��4
	
	private String orderField; // ����ʽ
	private String orderDirection; // ������
	public String keywords;

	// ���ݵĲ����������õĲ���
	private int currentPage = 1; // ��ǰҳ
	private int numPerPage = 20; // ÿҳ��ʾ��������¼numPerPage
	// ��ѯ���ݿ�
	private List<Object> list; // ��ҳ�������б�
	private int totalCount; // �ܼ�¼��
	// ����
	private int pageCount; // ��ҳ��
	private int beginPageIndex; // ҳ���б�Ŀ�ʼ������������
	private int endPageIndex; // ҳ���б�Ľ���������������

	public DwzPage() {
		super();
	}

	/**
	 * ֻ����4����Ҫ�����ԣ����Զ��ļ��������3�����Ե�ֵ
	 * 
	 * @param currentPage
	 * @param numPerPage
	 * @param list
	 * @param totalCount
	 */
	public DwzPage(int currentPage, int numPerPage, int totalCount) {
		this.currentPage = currentPage;
		this.numPerPage = numPerPage;
		this.setTotalCount(totalCount);
		// ���� pageCount
		pageCount = (totalCount + numPerPage - 1) / numPerPage;

		// ���� beginPageIndex �� endPageIndex
		// >> ��ҳ��С�ڵ���10ҳʱ��ȫ����ʾ
		if (pageCount <= 10) {
			beginPageIndex = 1;
			endPageIndex = pageCount;
		}
		// >> ��ҳ�����10ҳʱ����ֻ��ʾ��ǰҳ�����Ĺ�10��ҳ��
		else {
			// Ĭ����ʾ ǰ4ҳ + ��ǰҳ + ��5ҳ
			beginPageIndex = currentPage - 4; // 7 - 4 = 3;
			endPageIndex = currentPage + 5; // 7 + 5 = 12; --> 3 ~ 12
			// ���ǰ�治��4��ҳ��ʱ������ʾǰ10ҳ
			if (beginPageIndex < 1) {
				beginPageIndex = 1;
				endPageIndex = 10;
			}
			// ������治��5��ҳ��ʱ������ʾ��10ҳ
			else if (endPageIndex > pageCount) {
				endPageIndex = pageCount;
				beginPageIndex = pageCount - 9;
			}
		}
	}

    public int getPageNumShown() {
        return pageNumShown;
    }

    public void setPageNumShown(int pageNumShown) {
        this.pageNumShown = pageNumShown;
    }

    public String getOrderField() {
        return orderField;
    }

    public void setOrderField(String orderField) {
        this.orderField = orderField;
    }

    public String getOrderDirection() {
        return orderDirection;
    }

    public void setOrderDirection(String orderDirection) {
        this.orderDirection = orderDirection;
    }

    public String getKeywords() {
        return keywords;
    }

    public void setKeywords(String keywords) {
        this.keywords = keywords;
    }

    public int getCurrentPage() {
        return currentPage;
    }

    public void setCurrentPage(int currentPage) {
        this.currentPage = currentPage;
    }

    public int getNumPerPage() {
        return numPerPage;
    }

    public void setNumPerPage(int numPerPage) {
        this.numPerPage = numPerPage;
    }

    public List<Object> getList() {
        return list;
    }

    public void setList(List<Object> list) {
        this.list = list;
    }

    public int getPageCount() {
        return pageCount;
    }

    public void setPageCount(int pageCount) {
        this.pageCount = pageCount;
    }

    public int getBeginPageIndex() {
        return beginPageIndex;
    }

    public void setBeginPageIndex(int beginPageIndex) {
        this.beginPageIndex = beginPageIndex;
    }

    public int getEndPageIndex() {
        return endPageIndex;
    }

    public void setEndPageIndex(int endPageIndex) {
        this.endPageIndex = endPageIndex;
    }

	public int getTotalCount() {
		return totalCount;
	}

	public void setTotalCount(int totalCount) {
		this.totalCount = totalCount;
	}


	
}
